﻿



using System;
using System.ServiceModel;
using Demo.DataObjects;
using Demo.Infrastructure;

namespace Demo.ServiceContracts
{
    [ServiceContract(Namespace="http://www.demo.com")]
public interface IUserService
    {
        /// <summary>
        /// 获取用户传输对象
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <returns>用户传输对象</returns>
        [OperationContract()]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Get)]
        UserDTO GetUserDTOWithName(string userName);
        /// <summary>
        /// 用户名是否存在
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <returns>存在：True,否则：Flase</returns>
        [OperationContract]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Get)]
        bool ExistsWithUserName(string userName);
        /// <summary>
        /// 用户名是否存在
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <param name="password">用户密码</param>
        /// <returns>存在：True,否则：Flase</returns>
        [OperationContract]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Get)]
        bool Exists(string userName,string password);
        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <param name="password">用户密码</param>
        /// <param name="roleID">角色ID</param>
        [OperationContract]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Put)]
        void CreateUser(string userName,string password,Int32 roleID);
        /// <summary>
        /// 修改用户密码
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <param name="password">旧密码</param>
        /// <param name="newPassword">新密码</param>
        /// <returns>成功：True,否则：Flase</returns>
        [OperationContract]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Remove, "GetUserDTOWithName")]
        bool ChangePassword(string userName,string password,string newPassword);
        /// <summary>
        /// 修改用户角色
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <param name="roleID">角色ID</param>
        /// <returns>成功：True,否则：Flase</returns>
        [OperationContract]
        [FaultContract(typeof(FaultData))]
        bool ChangeRole(string userName, Int32 roleID);

    }
}
